package com.mmc.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 用户实体
 *
 * @author kunfe
 * @since 2024-01-01
 */
@Data
@TableName("sys_user")
@Schema(description = "用户实体")
public class User {

    @Schema(description = "用户ID")
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @Schema(description = "用户名")
    private String username;

    @Schema(description = "密码")
    @JsonIgnore
    private String password;

    @Schema(description = "真实姓名")
    private String realName;

    @Schema(description = "昵称")
    private String nickname;

    @Schema(description = "头像")
    private String avatar;

    @Schema(description = "邮箱")
    private String email;

    @Schema(description = "手机号")
    private String phone;

    @Schema(description = "性别：0-未知，1-男，2-女")
    private Integer gender;

    @Schema(description = "生日")
    private String birthday;

    @Schema(description = "部门ID")
    private Long deptId;

    @Schema(description = "部门名称")
    @TableField(exist = false)
    private String deptName;

    @Schema(description = "岗位")
    private String position;

    @Schema(description = "个人简介")
    private String intro;

    @Schema(description = "状态：0-禁用，1-正常")
    private Integer status;

    @Schema(description = "用户类型：0-系统用户，1-普通用户")
    private Integer userType;

    @Schema(description = "最后登录时间")
    private LocalDateTime lastLoginTime;

    @Schema(description = "最后登录IP")
    private String lastLoginIp;

    @Schema(description = "密码更新时间")
    private LocalDateTime passwordUpdateTime;

    @Schema(description = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @Schema(description = "创建人")
    @TableField(fill = FieldFill.INSERT)
    private String createBy;

    @Schema(description = "更新人")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    @Schema(description = "是否删除：0-未删除，1-已删除")
    @TableLogic
    private Integer deleted;

    @Schema(description = "备注")
    private String remark;

    // 关联字段
    @Schema(description = "角色ID列表")
    @TableField(exist = false)
    private List<Long> roleIds;

    @Schema(description = "角色列表")
    @TableField(exist = false)
    private List<Role> roles;

    @Schema(description = "权限列表")
    @TableField(exist = false)
    private List<String> permissions;

    @Schema(description = "菜单列表")
    @TableField(exist = false)
    private List<Menu> menus;
} 